package com.shiguiwu.springmybatis.designpattern.prototype;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @description: 小猪佩奇
 * @author: stone
 * @date: Created by 2021/2/22 21:30
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.designpattern.prototype
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Pig implements Cloneable {

    private String name;

    private Integer age;

    private Date birthday;

    //深克隆

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Pig clone = (Pig) super.clone();
        Date birthday = clone.getBirthday();
        clone.setBirthday((Date) birthday.clone());
        return clone;
    }
}
